|
@@ -4,19 +4,25 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.EmployeeDao;
|
|
|
import com.ym.mec.biz.dal.dao.ReplacementInstrumentActivityDao;
|
|
|
+import com.ym.mec.biz.dal.dao.ReplacementInstrumentDao;
|
|
|
+import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
|
|
|
import com.ym.mec.biz.dal.dto.StudentInstrumentExportDto;
|
|
|
-import com.ym.mec.biz.dal.entity.Employee;
|
|
|
-import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentRegistration;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
|
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
|
import com.ym.mec.biz.dal.page.ReplacementInstrumentActivityQueryInfo;
|
|
|
import com.ym.mec.biz.service.ReplacementInstrumentActivityService;
|
|
|
+import com.ym.mec.biz.service.ReplacementInstrumentCooperationService;
|
|
|
+import com.ym.mec.biz.service.SysMessageService;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
+import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import com.ym.mec.util.excel.POIUtil;
|
|
|
+import com.ym.mec.util.http.HttpUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -24,15 +30,14 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@RequestMapping("replacementInstrumentActivity")
|
|
|
@Api(tags = "乐器置换-调查问卷服务")
|
|
@@ -47,6 +52,14 @@ public class ReplacementInstrumentActivityController extends BaseController {
|
|
|
private EmployeeDao employeeDao;
|
|
|
@Autowired
|
|
|
private ReplacementInstrumentActivityDao replacementInstrumentActivityDao;
|
|
|
+ @Autowired
|
|
|
+ private ReplacementInstrumentCooperationService replacementInstrumentCooperationService;
|
|
|
+ @Autowired
|
|
|
+ private ReplacementInstrumentDao replacementInstrumentDao;
|
|
|
+ @Autowired
|
|
|
+ private SysConfigDao sysConfigDao;
|
|
|
+ @Autowired
|
|
|
+ private SysMessageService sysMessageService;
|
|
|
|
|
|
@ApiOperation(value = "分页查询列表")
|
|
|
@GetMapping("/queryPage")
|
|
@@ -67,7 +80,6 @@ public class ReplacementInstrumentActivityController extends BaseController {
|
|
|
return failed("非法请求");
|
|
|
}
|
|
|
}
|
|
|
- queryInfo.setHasInstrumentsId(true);
|
|
|
return succeed(replacementInstrumentActivityService.getPageList(queryInfo));
|
|
|
}
|
|
|
|
|
@@ -78,20 +90,36 @@ public class ReplacementInstrumentActivityController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "修改")
|
|
|
- @GetMapping("/update")
|
|
|
+ @PostMapping("/update")
|
|
|
@PreAuthorize("@pcs.hasPermissions('replacementInstrumentActivity/update')")
|
|
|
public HttpResponseResult<ReplacementInstrumentActivity> update(ReplacementInstrumentActivity replacementInstrumentActivity) {
|
|
|
ReplacementInstrumentActivity oldReplacementInstrumentActivity = replacementInstrumentActivityDao.getLock(replacementInstrumentActivity.getId());
|
|
|
if (!oldReplacementInstrumentActivity.getPayStatus().equals(0)) {
|
|
|
return failed("支付中、已支付的乐器置换,不能修改");
|
|
|
}
|
|
|
- if (oldReplacementInstrumentActivity.getInstrumentsId().equals(replacementInstrumentActivity.getInstrumentsId())) {
|
|
|
- return succeed();
|
|
|
+
|
|
|
+ ReplacementInstrumentCooperation byCooperationId = replacementInstrumentCooperationService.getByCooperationId(oldReplacementInstrumentActivity.getCooperationOrganId());
|
|
|
+ if (byCooperationId.getOpenPay().equals(YesOrNoEnum.YES) && oldReplacementInstrumentActivity.getInstrumentsId() == null && replacementInstrumentActivity.getInstrumentsId() != null) {
|
|
|
+ ReplacementInstrument replacementInstrument = replacementInstrumentDao.get(replacementInstrumentActivity.getInstrumentsId());
|
|
|
+ Map<Integer, String> userMap = new HashMap<>();
|
|
|
+ Map<Integer, String> userPhoneMap = new HashMap<>();
|
|
|
+ Integer userId = oldReplacementInstrumentActivity.getUserId();
|
|
|
+ String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
|
|
|
+ String pushUrl = baseApiUrl + "/#/questionGoodsSale?id=";
|
|
|
+ userMap.put(userId, userId.toString());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.REPLACEMENT_PAY_PUSH,
|
|
|
+ userMap, null, 0, "5?" + pushUrl + replacementInstrumentActivity.getId(), "STUDENT", replacementInstrument.getBrand(), "");
|
|
|
+
|
|
|
+ userPhoneMap.put(userId, oldReplacementInstrumentActivity.getMobileNo());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.REPLACEMENT_PAY_PUSH,
|
|
|
+ userPhoneMap, null, 0, null, "STUDENT", replacementInstrument.getBrand(), HttpUtil.getSortUrl(pushUrl + replacementInstrumentActivity.getId()));
|
|
|
}
|
|
|
+
|
|
|
oldReplacementInstrumentActivity.setSubjectId(replacementInstrumentActivity.getSubjectId());
|
|
|
oldReplacementInstrumentActivity.setInstrumentsId(replacementInstrumentActivity.getInstrumentsId());
|
|
|
oldReplacementInstrumentActivity.setUpdateTime(new Date());
|
|
|
replacementInstrumentActivityService.update(oldReplacementInstrumentActivity);
|
|
|
+
|
|
|
return succeed(replacementInstrumentActivity);
|
|
|
}
|
|
|
|
|
@@ -114,19 +142,30 @@ public class ReplacementInstrumentActivityController extends BaseController {
|
|
|
throw new BizException("非法请求");
|
|
|
}
|
|
|
}
|
|
|
- queryInfo.setHasInstrumentsId(true);
|
|
|
queryInfo.setRows(99999);
|
|
|
PageInfo<ReplacementInstrumentActivityStatDto> pageList = replacementInstrumentActivityService.getPageList(queryInfo);
|
|
|
|
|
|
if (pageList.getTotal() <= 0) {
|
|
|
throw new BizException("没有可导出的记录");
|
|
|
}
|
|
|
+ for (ReplacementInstrumentActivityStatDto row : pageList.getRows()) {
|
|
|
+ if (row.getQuestionResult().substring(0, 1).equals("1")) {
|
|
|
+ row.setHasYesFirstAnswer("是");
|
|
|
+ } else {
|
|
|
+ row.setHasYesFirstAnswer("否");
|
|
|
+ }
|
|
|
+ if(row.getInstrumentsId() == null){
|
|
|
+ row.setHasInstrumentsId("否");
|
|
|
+ }else {
|
|
|
+ row.setHasInstrumentsId("是");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
OutputStream outputStream = response.getOutputStream();
|
|
|
HSSFWorkbook workbook = null;
|
|
|
try {
|
|
|
- String[] header = {"合作单位编号", "合作单位", "学员编号", "学员姓名", "联系电话", "声部", "品牌", "型号"};
|
|
|
- String[] body = {"cooperationOrganId", "cooperationOrganName", "userId", "userName", "mobileNo", "subjectName", "brand", "specification"};
|
|
|
+ String[] header = {"分部", "合作单位编号", "合作单位", "学员编号", "学员姓名", "联系电话", "声部", "品牌", "型号", "是否参与市赛", "是否置换乐器"};
|
|
|
+ String[] body = {"organName", "cooperationOrganId", "cooperationOrganName", "userId", "userName", "mobileNo", "subjectName", "brand", "specification","hasYesFirstAnswer","hasInstrumentsId"};
|
|
|
workbook = POIUtil.exportExcel(header, body, pageList.getRows());
|
|
|
response.setContentType("application/octet-stream");
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=replacement-" + DateUtil.getDate(new Date()) + ".xls");
|