| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- package cn.com.goldenwater.dcproj.controller.tac;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.constValue.SmsCodeEnum;
- import cn.com.goldenwater.dcproj.dto.TacInspYearBatchGroupDto;
- import cn.com.goldenwater.dcproj.dto.TacInspYearBatchGroupExportDto;
- import cn.com.goldenwater.dcproj.model.TacInspYearBatchArea;
- import cn.com.goldenwater.dcproj.model.TacInspYearBatchGroup;
- import cn.com.goldenwater.dcproj.model.TacInspYearBatchObj;
- import cn.com.goldenwater.dcproj.model.TacWorkerB;
- import cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupParam;
- import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
- import cn.com.goldenwater.dcproj.service.TacInspYearBatchGroupService;
- import cn.com.goldenwater.dcproj.utils.expExcel.ExportUtil;
- import cn.com.goldenwater.id.util.UuidUtil;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.apache.commons.lang3.StringUtils;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import javax.servlet.http.HttpServletResponse;
- import java.time.LocalDateTime;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.List;
- /**
- * @author lune
- * @date 2019-9-6
- */
- @Api(value = "TAC 稽察年度批次稽察组表管理", tags = "TAC 稽察年度批次稽察组表管理")
- @RestController
- @RequestMapping("/tac/insp/year/batch/group")
- public class TacInspYearBatchGroupController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private TacInspYearBatchGroupService tacInspYearBatchGroupService;
- @Autowired
- private OlBisInspOrgService olBisInspOrgService;
- @ApiOperation(value = "添加/修改稽察年度批次稽察组表")
- @RequestMapping(value = "", method = RequestMethod.POST)
- public BaseResponse<TacInspYearBatchGroup> insert(@ApiParam(name = "tacInspYearBatchGroup", value = "TacInspYearBatchGroup", required = true) @RequestBody TacInspYearBatchGroup tacInspYearBatchGroup) {
- if (StringUtils.isBlank(tacInspYearBatchGroup.getId())) {
- String uuid = UuidUtil.uuid(); // 生成uuid
- tacInspYearBatchGroup.setId(uuid);
- tacInspYearBatchGroupService.insert(tacInspYearBatchGroup);
- } else {
- tacInspYearBatchGroupService.update(tacInspYearBatchGroup);
- }
- return buildSuccessResponse(tacInspYearBatchGroup);
- }
- @ApiOperation(value = "根据ID删除稽察年度批次稽察组表")
- @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
- public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- int ret = tacInspYearBatchGroupService.deleteGroupById(id, olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- return buildSuccessResponse();
- }
- @ApiOperation(value = "删除督查组")
- @RequestMapping(value = "/deleteGroupList", method = RequestMethod.POST)
- public BaseResponse deleteGroupList(@RequestBody TacInspYearBatchGroupDto dto) {
- dto.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- int a = tacInspYearBatchGroupService.deleteGroupList(dto);
- return buildSuccessResponse(a);
- }
- @ApiOperation(value = "修改督查组区域列表")
- @RequestMapping(value = "/updateGroupArea", method = RequestMethod.POST)
- public BaseResponse<TacInspYearBatchGroup> updateGroupArea(@RequestBody TacInspYearBatchGroup group) {
- group.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- int a = tacInspYearBatchGroupService.updateGroupArea(group);
- return buildSuccessResponse(group);
- }
- @ApiOperation(value = "根据ID获取稽察年度批次稽察组表(单表)")
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public BaseResponse<TacInspYearBatchGroup> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- TacInspYearBatchGroup tacInspYearBatchGroup = tacInspYearBatchGroupService.get(id);
- return buildSuccessResponse(tacInspYearBatchGroup);
- }
- @ApiOperation(value = "根据ID获取稽察年度批次稽察组表")
- @RequestMapping(value = "/getGroupById/{id}", method = RequestMethod.GET)
- public BaseResponse<TacInspYearBatchGroup> getGroupById(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- TacInspYearBatchGroup tacInspYearBatchGroup = tacInspYearBatchGroupService.getGroupById(id, olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- return buildSuccessResponse(tacInspYearBatchGroup);
- }
- @ApiOperation(value = "获取稽察年度批次稽察组表(列表所有)")
- @RequestMapping(value = "/list", method = RequestMethod.POST)
- public BaseResponse<List<TacInspYearBatchGroup>> list(@ApiParam(name = "tacInspYearBatchGroupParam", value = "tacInspYearBatchGroupParam", required = true) @RequestBody TacInspYearBatchGroupParam tacInspYearBatchGroupParam) {
- tacInspYearBatchGroupParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- List<TacInspYearBatchGroup> tacInspYearBatchGroupList = tacInspYearBatchGroupService.findList(tacInspYearBatchGroupParam);
- return buildSuccessResponse(tacInspYearBatchGroupList);
- }
- @ApiOperation(value = "获取稽察年度批次稽察组表(列表--分页)")
- @RequestMapping(value = "/page", method = RequestMethod.POST)
- public BaseResponse<PageInfo<TacInspYearBatchGroup>> page(@ApiParam(name = "tacInspYearBatchGroupParam", value = "tacInspYearBatchGroupParam", required = true) @RequestBody TacInspYearBatchGroupParam tacInspYearBatchGroupParam) {
- tacInspYearBatchGroupParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- PageInfo<TacInspYearBatchGroup> tacInspYearBatchGroupList = tacInspYearBatchGroupService.findPageInfo(tacInspYearBatchGroupParam);
- return buildSuccessResponse(tacInspYearBatchGroupList);
- }
- @ApiOperation(value = "保存督查组")
- @RequestMapping(value = "/insertGroupList", method = RequestMethod.POST)
- public BaseResponse insertGroupList(TacInspYearBatchGroupDto groupDto) {
- groupDto.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- int a = this.tacInspYearBatchGroupService.insertGroupList(groupDto);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "获取组列表")
- @RequestMapping(value = "/getGroupList", method = RequestMethod.POST)
- public BaseResponse<List<TacInspYearBatchGroup>> getGroupList(@RequestBody TacInspYearBatchGroupParam tacInspYearBatchGroupParam, HttpServletResponse response) {
- tacInspYearBatchGroupParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- List<TacInspYearBatchGroup> list = tacInspYearBatchGroupService.getGroupList(tacInspYearBatchGroupParam);
- if ("1".equals(tacInspYearBatchGroupParam.getIsExport())) {
- List<TacInspYearBatchGroupExportDto> dtoList = new ArrayList<TacInspYearBatchGroupExportDto>(list.size());
- List<String> columns = new ArrayList<>();
- columns.add("orgId");
- columns.add("province");
- columns.add("rgstrId");
- columns.add("groupId");
- columns.add("objId");
- if (list.size() > 0) {
- for(TacInspYearBatchGroup group: list){
- TacInspYearBatchGroupExportDto dto = new TacInspYearBatchGroupExportDto();
- dto.setYear(group.getYear());
- dto.setBatch(group.getBatch());
- dto.setGroupNm(group.getGroupNm());
- dto.setSttm(convertDateToLocalDateTime(group.getStTm()));
- dto.setEntm(convertDateToLocalDateTime(group.getEnTm()));
- String areas = "";
- if(group.getAreaList() != null && group.getAreaList().size() > 0){
- for (TacInspYearBatchArea area : group.getAreaList()) {
- areas = area.getAdName() + "," + areas;
- }
- if (areas.length() > 0) {
- areas = areas.substring(0, areas.lastIndexOf(","));
- }
- }
- dto.setAreas(areas);
- String objNms = "";
- String types = "";
- if(group.getObjList() != null && group.getObjList().size() > 0){
- for (TacInspYearBatchObj batchObj : group.getObjList()) {
- objNms = batchObj.getOjbNm() + "," + objNms;
- types = batchObj.getType() + "," + types;
- }
- if (objNms.length() > 0) {
- objNms = objNms.substring(0, objNms.lastIndexOf(","));
- types = types.substring(0, types.lastIndexOf(","));
- }
- }
- dto.setObjNms(objNms);
- dto.setTypes(types);
- String worker20s = "";
- String worker19s = "";
- String worker11s = "";
- String worker12s = "";
- String worker13s = "";
- String worker14s = "";
- String worker15s = "";
- String worker16s = "";
- if (group.getWorkersList() != null && group.getWorkersList().size() > 0) {
- for (TacWorkerB b : group.getWorkersList()) {
- String roleType = b.getRoleType();
- if("20".equals(roleType)){
- worker20s = b.getName() + "," + worker20s;
- }else if("19".equals(roleType)){
- worker19s = b.getName() + "," + worker19s;
- }else if("11".equals(roleType)){
- worker11s = b.getName() + "," + worker11s;
- }else if("12".equals(roleType)){
- worker12s = b.getName() + "," + worker12s;
- }else if("13".equals(roleType)){
- worker13s = b.getName() + "," + worker13s;
- }else if("14".equals(roleType)){
- worker14s = b.getName() + "," + worker14s;
- }else if("15".equals(roleType)){
- worker15s = b.getName() + "," + worker15s;
- }else if("16".equals(roleType)){
- worker16s = b.getName() + "," + worker16s;
- }
- }
- if (worker20s.length() > 0) {
- worker20s = worker20s.substring(0, worker20s.lastIndexOf(","));
- }
- if (worker19s.length() > 0) {
- worker19s = worker19s.substring(0, worker19s.lastIndexOf(","));
- }
- if (worker11s.length() > 0) {
- worker11s = worker11s.substring(0, worker11s.lastIndexOf(","));
- }
- if (worker12s.length() > 0) {
- worker12s = worker12s.substring(0, worker12s.lastIndexOf(","));
- }
- if (worker13s.length() > 0) {
- worker13s = worker13s.substring(0, worker13s.lastIndexOf(","));
- }
- if (worker14s.length() > 0) {
- worker14s = worker14s.substring(0, worker14s.lastIndexOf(","));
- }
- if (worker15s.length() > 0) {
- worker15s = worker15s.substring(0, worker15s.lastIndexOf(","));
- }
- if (worker16s.length() > 0) {
- worker16s = worker16s.substring(0, worker16s.lastIndexOf(","));
- }
- }
- dto.setWorker20(worker20s);
- dto.setWorker19(worker19s);
- dto.setWorker11(worker11s);
- dto.setWorker12(worker12s);
- dto.setWorker13(worker13s);
- dto.setWorker14(worker14s);
- dto.setWorker15(worker15s);
- dto.setWorker16(worker16s);
- dto.setRemark(group.getRemark());
- dtoList.add(dto);
- }
- }
- ExportUtil.exportExcel(dtoList, response, "稽察历史计划列表", columns, TacInspYearBatchGroupExportDto.class);
- }
- return buildSuccessResponse(list);
- }
- private String convertDateToLocalDateTime(Date date){
- if(null == date){
- return "";
- }
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(date);
- LocalDateTime localDateTime = LocalDateTime.of(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH),0,0,0);
- if(null != localDateTime){
- String dateStr = String.format("%d年%d月%d日",localDateTime.getYear(),localDateTime.getMonthValue(),localDateTime.getDayOfMonth());
- return dateStr;
- }else {
- return "";
- }
- }
- @ApiOperation(value = "获取组列表app")
- @RequestMapping(value = "/getGroupListApp", method = RequestMethod.POST)
- public BaseResponse<List<TacInspYearBatchGroup>> getGroupListApp(@RequestBody TacInspYearBatchGroupParam tacInspYearBatchGroupParam) {
- tacInspYearBatchGroupParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- List<TacInspYearBatchGroup> list = tacInspYearBatchGroupService.getGroupListApp(tacInspYearBatchGroupParam);
- return buildSuccessResponse(list);
- }
- @ApiOperation(value = "批量修改组列表")
- @RequestMapping(value = "/updateGroupList", method = RequestMethod.POST)
- public BaseResponse updateGroupList(@RequestBody TacInspYearBatchGroupDto dto) {
- dto.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- int a = tacInspYearBatchGroupService.updateGroupList(dto);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据分组id发送短信")
- @RequestMapping(value = "/sendGroupMessage", method = RequestMethod.POST)
- public BaseResponse sendGroupMessage(@RequestBody TacInspYearBatchGroupParam tacInspYearBatchGroupParam) {
- if (StringUtils.isBlank(tacInspYearBatchGroupParam.getYearBatchId())) {
- return buildFailResponse(17001, "批次id不能为空");
- }
- if (StringUtils.isBlank(tacInspYearBatchGroupParam.getId())) {
- return buildFailResponse(17001, "组id不能为空");
- }
- try{
- tacInspYearBatchGroupParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- String resultCode = tacInspYearBatchGroupService.sendGroupMessage(tacInspYearBatchGroupParam);
- if (SmsCodeEnum.SUCCESS.getKey().equals(resultCode)) {
- return buildSuccessResponse(SmsCodeEnum.SUCCESS.getDesc());
- } else if (SmsCodeEnum.NO_USER.getKey().equals(resultCode)) {
- return buildFailResponse(10002, SmsCodeEnum.NO_USER.getDesc());
- } else if (SmsCodeEnum.NO_MEET.getKey().equals(resultCode)) {
- return buildFailResponse(10003, SmsCodeEnum.NO_MEET.getDesc());
- } else if (SmsCodeEnum.NO_COVERAGE.getKey().equals(resultCode)) {
- return buildFailResponse(10005, SmsCodeEnum.NO_COVERAGE.getDesc());
- }else{
- return buildSuccessResponse(SmsCodeEnum.SUCCESS.getDesc());
- }
- }catch (Exception e) {
- return buildFailResponse("系统异常请联系管理员");
- }
- }
- @ApiOperation(value = "固定分组人员")
- @RequestMapping(value = "/confirmerGroup", method = RequestMethod.POST)
- public BaseResponse confirmerGroup(@RequestBody TacInspYearBatchGroupParam tacInspYearBatchGroupParam) throws Exception {
- // 固定分组人员后不能对该组人员进行人员分配,人员刷新,人员单角色刷新操作,可对人员单独添加,修改,删除
- if (StringUtils.isBlank(tacInspYearBatchGroupParam.getId())) {
- return buildFailResponse(17001, "组别id不能为空");
- }
- return buildSuccessResponse(tacInspYearBatchGroupService.confirmerGroup(tacInspYearBatchGroupParam));
- }
- }
|