|
|
@ -6,19 +6,24 @@ import com.epmet.commons.tools.dto.form.PageFormDTO; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.validator.AssertUtils; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|
|
|
import com.epmet.constant.IcResiUserConstant; |
|
|
|
import com.epmet.dto.IcTripReportRecordDTO; |
|
|
|
import com.epmet.dto.form.IcTripReportFormDTO; |
|
|
|
import com.epmet.dto.form.MyReportedTripFormDTO; |
|
|
|
import com.epmet.dto.form.PageTripReportFormDTO; |
|
|
|
import com.epmet.service.IcTripReportRecordService; |
|
|
|
import org.apache.commons.io.IOUtils; |
|
|
|
import org.apache.commons.lang3.ArrayUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.http.HttpHeaders; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
@ -50,12 +55,6 @@ public class IcTripReportRecordController { |
|
|
|
return new Result<PageData<IcTripReportRecordDTO>>().ok(page); |
|
|
|
} |
|
|
|
|
|
|
|
@RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET}) |
|
|
|
public Result<IcTripReportRecordDTO> get(@PathVariable("id") String id){ |
|
|
|
IcTripReportRecordDTO data = icTripReportRecordService.get(id); |
|
|
|
return new Result<IcTripReportRecordDTO>().ok(data); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* pc: 行程上报-新增 |
|
|
|
* @param formDTO |
|
|
@ -66,7 +65,7 @@ public class IcTripReportRecordController { |
|
|
|
public Result save(@LoginUser TokenDto tokenDto,@RequestBody IcTripReportFormDTO formDTO){ |
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
formDTO.setCurrentStaffId(tokenDto.getUserId()); |
|
|
|
ValidatorUtils.validateEntity(formDTO,IcTripReportFormDTO.PcRequired.class,IcTripReportFormDTO.PcInternalGroup.class); |
|
|
|
ValidatorUtils.validateEntity(formDTO,IcTripReportFormDTO.PcAddRequired.class,IcTripReportFormDTO.PcAddOrUpdateInternalGroup.class); |
|
|
|
if(IcResiUserConstant.USER_TYPE_IC_RESI.equals(formDTO.getUserType())){ |
|
|
|
ValidatorUtils.validateEntity(formDTO,IcTripReportFormDTO.IcResiInternalGroup.class); |
|
|
|
} |
|
|
@ -74,20 +73,35 @@ public class IcTripReportRecordController { |
|
|
|
return new Result().ok(id); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* pc: 行程上报-修改 |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@NoRepeatSubmit |
|
|
|
@PostMapping("update") |
|
|
|
public Result update(@RequestBody IcTripReportRecordDTO dto){ |
|
|
|
//效验数据
|
|
|
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|
|
|
icTripReportRecordService.update(dto); |
|
|
|
return new Result(); |
|
|
|
public Result update(@LoginUser TokenDto tokenDto,@RequestBody IcTripReportFormDTO formDTO){ |
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
formDTO.setCurrentStaffId(tokenDto.getUserId()); |
|
|
|
ValidatorUtils.validateEntity(formDTO,IcTripReportFormDTO.PcUpdateRequired.class,IcTripReportFormDTO.PcAddOrUpdateInternalGroup.class); |
|
|
|
if(IcResiUserConstant.USER_TYPE_IC_RESI.equals(formDTO.getUserType())){ |
|
|
|
ValidatorUtils.validateEntity(formDTO,IcTripReportFormDTO.IcResiInternalGroup.class); |
|
|
|
} |
|
|
|
return new Result().ok(icTripReportRecordService.update(formDTO)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* pc:行程上报-删除 |
|
|
|
* |
|
|
|
* @param ids |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("delete") |
|
|
|
public Result delete(@RequestBody String[] ids){ |
|
|
|
//效验数据
|
|
|
|
AssertUtils.isArrayEmpty(ids, "id"); |
|
|
|
icTripReportRecordService.delete(ids); |
|
|
|
public Result delete(@LoginUser TokenDto tokenDto, @RequestBody String[] ids) { |
|
|
|
if (ArrayUtils.isEmpty(ids)) { |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
icTripReportRecordService.delete(tokenDto.getCustomerId(),tokenDto.getUserId(),ids); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
@ -119,4 +133,29 @@ public class IcTripReportRecordController { |
|
|
|
return new Result<List<IcTripReportRecordDTO>>().ok(icTripReportRecordService.resiList(formDTO)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* pc:行程上报-下载模板 |
|
|
|
* @param response |
|
|
|
* @throws IOException |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "template-download", method = {RequestMethod.GET, RequestMethod.POST}) |
|
|
|
public void downloadTemplate(HttpServletResponse response) throws IOException { |
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
response.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "Content-Disposition"); |
|
|
|
//response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel");
|
|
|
|
response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|
|
|
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("行程上报导入模板", "UTF-8") + ".xlsx"); |
|
|
|
|
|
|
|
InputStream is = this.getClass().getClassLoader().getResourceAsStream("excel/trip_report_import_template.xlsx"); |
|
|
|
try { |
|
|
|
ServletOutputStream os = response.getOutputStream(); |
|
|
|
IOUtils.copy(is, os); |
|
|
|
} finally { |
|
|
|
if (is != null) { |
|
|
|
is.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|