use of com.eservice.api.model.contact_form.ContactForm in project sinsim by WilsonHu.
the class CommonService method pushLxdMsgToAftersale.
/**
* 推送公众号消息给轮到联系单签核的人(通过售后系统)
* @param cs
* @param cf
* @param haveReject 是否驳回 ( 虽然这个信息可以从cs中提取,但是调用该函数的地方前面已经提前过了,方便用)
*/
public void pushLxdMsgToAftersale(ContactSign cs, ContactForm cf, boolean haveReject, String msgInfo) {
// 指定格式,因为售后解析要用到
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 指定北京时间
formatter.setTimeZone(TimeZone.getTimeZone("GMT+8"));
String createDateStr = formatter.format(cf.getCreateDate());
if (cs.getCurrentStep().equals(Constant.SIGN_FINISHED)) {
// 审核完成时,通知发起人
logger.info(cf.getContactTitle() + ", 审核完成时,通知发起人");
List<UserDetail> userList = userService.selectUsers(cf.getApplicantPerson(), null, null, null, null, 1);
if (userList.isEmpty() || userList == null) {
logger.error("根据 " + cf.getApplicantPerson() + "找不到User");
} else {
// 找到发起人
UserDetail toUser = userList.get(0);
commonService.sendSignInfoViWxMsg(toUser.getAccount(), "", cf.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
}
} else {
/**
* 审核没有结束,
* 驳回 :推送给参与签核的人,以及发起人
* 无驳回:推送给下一个轮到签核的角色
*/
Role role = roleService.findBy("roleName", cs.getCurrentStep());
if (role == null) {
logger.error("根据该 role_name " + cs.getCurrentStep() + "找不到Role");
return;
}
List<UserDetail> userList = userService.selectUsers(null, null, role.getId(), null, null, 1);
if (haveReject) {
List<User> userNameList = commonService.getUsersInLxdSign(cs);
for (User toUser : userNameList) {
logger.info("联系单被拒绝,发给参与签核的人 " + toUser.getAccount());
commonService.sendSignInfoViWxMsg(toUser.getAccount(), "", cf.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
}
logger.info("联系单被拒绝,发给发起签核的人 " + cf.getApplicantPerson());
commonService.sendSignInfoViWxMsg(cf.getApplicantPerson(), "", cf.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
} else {
// 如果是销售部经理还要细分发给哪个经理,
if (role.getRoleName().equals(Constant.SING_STEP_SALES_MANAGER)) {
String userSalesManagerAccount = cf.getDesignatedSaleManager();
logger.info(" 发给被指定的销售部经理 " + userSalesManagerAccount);
commonService.sendSignInfoViWxMsg(userSalesManagerAccount, "", cf.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
} else {
if (userList.isEmpty() || userList == null) {
logger.error("根据该roleId " + role.getId() + "找不到User");
} else {
// 可能有多个负责人,比如研发部现在就两个经理,都通知。
for (UserDetail toUser : userList) {
ContactForm contactForm = contactFormService.findById(cs.getContactFormId());
logger.info(" 发给参与签核的角色(可能多个) " + toUser.getAccount());
commonService.sendSignInfoViWxMsg(toUser.getAccount(), "", contactForm.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
}
}
}
}
}
}
use of com.eservice.api.model.contact_form.ContactForm in project sinsim by WilsonHu.
the class ContactFormController method checkTheContactFormValid.
@PostMapping("/checkTheContactFormValid")
public Result checkTheContactFormValid(String contactForm) {
if (contactForm == null) {
return ResultGenerator.genFailResult("参数 contactFormDetail 不能为null ");
}
ContactForm contactForm1 = JSON.parseObject(contactForm, ContactForm.class);
if (contactForm1 == null) {
return ResultGenerator.genFailResult("错误,解析得到的 contactForm1为 null!");
}
/**
* 逐一检查各个必要参数的合法性
*/
if (contactForm1.getApplicantDepartment() == null) {
return ResultGenerator.genFailResult("错误,getApplicantDepartment 为 null!");
}
if (contactForm1.getContactTitle() == null) {
return ResultGenerator.genFailResult("错误,getContactTitle 为 null!");
}
// if(contactForm1.getOrderNum() == null){
// return ResultGenerator.genFailResult("错误,orderNum 为 null!");
// }
// 根据订单号找订单
MachineOrder machineOrder = machineOrderService.getMachineOrder(contactForm1.getOrderNum());
if (machineOrder == null) {
return ResultGenerator.genFailResult("错误,根据该订单号 找不到对应的订单 ");
}
return ResultGenerator.genSuccessResult("OK");
}
use of com.eservice.api.model.contact_form.ContactForm in project sinsim by WilsonHu.
the class ContactFormController method delete.
// 删除时,联系单对应的 变更条目,联系单签核,都删除。
@Transactional(rollbackFor = Exception.class)
@PostMapping("/delete")
public Result delete(@RequestParam Integer id) {
ContactForm cf = contactFormService.findById(id);
if (null == cf) {
return ResultGenerator.genFailResult("根据该id" + id + " 找不到对应的联系单");
}
if (cf.getContactType().equals(Constant.STR_LXD_TYPE_BIANGENG)) {
List<ChangeItem> ciList = changeItemService.selectChangeItemList(id);
for (int i = 0; i < ciList.size(); i++) {
changeItemService.deleteById(ciList.get(i).getId());
}
}
ContactSign cs = contactSignService.getContactSignByLxdId(id);
contactSignService.deleteById(cs.getId());
contactFormService.deleteById(id);
return ResultGenerator.genSuccessResult();
}
use of com.eservice.api.model.contact_form.ContactForm in project sinsim by WilsonHu.
the class ContactFormController method uploadAttachedFile.
/**
* 上传联系单附件文件 只保存文件,不保存数据库,保存路径返回给前端,前端统一写入
*
* @param request 参数带一个文件,以及一个lxdNum(联系单的编号,客户可见)
* @return 后端保存的文件名称(相对地址在: lxdAttachedSavedDir)
*/
@PostMapping("/uploadAttachedFile")
public Result uploadAttachedFile(HttpServletRequest request) {
try {
/**
* 联系单的编号,在保存文件时,文件名称中包含。
* 在第一次新建时,联系单单号 名称中包含 xxx, 这个在add时会倍更新,对应的文件也会重命名。
*/
String lxdNum = request.getParameterValues("lxdNum")[0];
// 联系单附件 or 联系单签核过程的附件
String type = request.getParameterValues("type")[0];
String uploadMan = request.getParameterValues("uploadMan")[0];
List<MultipartFile> fileList = ((MultipartHttpServletRequest) request).getFiles("file");
if (fileList == null || fileList.size() == 0) {
return ResultGenerator.genFailResult("Error: no available file");
}
MultipartFile file = fileList.get(0);
File dir = new File(lxdAttachedSavedDir);
if (!dir.exists()) {
dir.mkdir();
}
try {
int typeInt = 0;
if (type.equals(Constant.STRING_LXD_ATTACHED_FILE_BY_CREATER)) {
typeInt = Constant.LXD_ATTACHED_FILE_BY_CREATER;
} else if (type.equals(Constant.STRING_LXD_ATTACHED_FILE_DURING_SIGN)) {
typeInt = Constant.LXD_ATTACHED_FILE_DURING_SIGN;
}
// save file, 只保存文件,不保存数据库,保存路径返回给前端,前端统一写入 。
String resultPath = commonService.saveFile(lxdAttachedSavedDir, file, "", lxdNum, typeInt, 0);
if (resultPath == null || resultPath == "") {
return ResultGenerator.genFailResult("文件名为空,联系单附件上传失败!");
}
logger.info("====/contact/form/uploadAttachedFile(): success======== " + resultPath);
/**
* 如果是签核过程中上传的附件,在附件保存之后,还需要特别地把数据库更新。
*/
if (type.equals(Constant.STRING_LXD_ATTACHED_FILE_DURING_SIGN)) {
List<ContactFormDetail> list = contactFormService.selectContacts(lxdNum, null, null, null, null, null, // 可能有多个联系单,所以不能用 Constant.STR_LXD_CHECKING_FINISHED,
null, null, null, null, null, null, null);
if (list == null || list.isEmpty()) {
return ResultGenerator.genFailResult(lxdNum + " 找不到对应的联系单!");
}
//
ContactForm contactForm = list.get(0);
contactForm.setAttachedDuringSign(resultPath);
contactForm.setAttachedDuringSignMan(uploadMan);
contactFormService.update(contactForm);
}
return ResultGenerator.genSuccessResult(resultPath);
} catch (Exception e) {
e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return ResultGenerator.genFailResult("联系单附件 上传失败!" + e.getMessage());
}
} catch (Exception e) {
e.printStackTrace();
return ResultGenerator.genFailResult("联系单附件 上传失败!" + e.getMessage());
}
}
use of com.eservice.api.model.contact_form.ContactForm in project sinsim by WilsonHu.
the class ContactSignController method update.
/**
* 联系单审核的更新,同时更新对应的联系单
* @param contactSign
* @return
*/
@PostMapping("/update")
@Transactional(rollbackFor = Exception.class)
public Result update(String contactSign) {
if (contactSign == null || "".equals(contactSign)) {
ResultGenerator.genFailResult("联系单审核信息不能为空!");
}
logger.info("contactSign:" + contactSign);
ContactSign cs = JSON.parseObject(contactSign, ContactSign.class);
if (cs == null) {
ResultGenerator.genFailResult("审核信息JSON解析失败!");
}
ContactForm cf = contactFormService.findById(cs.getContactFormId());
if (null == cf) {
ResultGenerator.genFailResult("根据传入的签核信息里的联系单ID 找不到对应的联系单");
}
cs.setUpdateTime(new Date());
List<SignContentItem> contactSignContentList = JSON.parseArray(cs.getSignContent(), SignContentItem.class);
boolean haveReject = false;
String currentStep = "";
for (SignContentItem item : contactSignContentList) {
if (item.getResult().equals(Constant.SIGN_REJECT)) {
haveReject = true;
}
// 签核在初始化,则把当前步骤设为发起部门 --> 就是下个要签核的部门
if (item.getResult() == Constant.SIGN_INITIAL && item.getShenHeEnabled()) {
currentStep = roleService.findById(item.getRoleId()).getRoleName();
break;
}
}
// 都已经签核
if (!haveReject) {
if (currentStep.equals("")) {
currentStep = Constant.SIGN_FINISHED;
}
cs.setCurrentStep(currentStep);
}
contactSignService.update(cs);
String msgInfo = null;
if (haveReject) {
/**
* 被拒绝了,
* contactSign的每个状态,更新为 初始状态
* contactForm的状态,更新为 被拒绝。
*/
for (SignContentItem item : contactSignContentList) {
item.setResult(Constant.SIGN_INITIAL);
}
cs.setSignContent(JSONObject.toJSONString(contactSignContentList));
logger.warn("got Reject signContent: " + JSONObject.toJSONString(contactSignContentList));
contactSignService.update(cs);
cf.setStatus(Constant.STR_LXD_REJECTED);
contactFormService.update(cf);
/**
* 推送 "签核被拒绝"消息
*/
msgInfo = Constant.STR_MSG_PUSH_SIGN_REFUESED;
} else {
// 没有被拒,且刚刚开始
if (cf.getStatus().equals(Constant.STR_LXD_INITIAL)) {
cf.setStatus(Constant.STR_LXD_CHECKING);
}
// 没有被拒,且联系单签核完成
if (currentStep.equals(Constant.SIGN_FINISHED)) {
cf.setStatus(Constant.STR_LXD_CHECKING_FINISHED);
// 推送 "签核完成" 消息给 发起人
msgInfo = Constant.STR_MSG_PUSH_SIGN_DONE;
} else {
// 推送 "轮到签核" 消息给 轮到联系单签核的人
msgInfo = Constant.STR_MSG_PUSH_IS_TURN_TO_SIGN;
}
contactFormService.update(cf);
}
commonService.pushLxdMsgToAftersale(cs, cf, haveReject, msgInfo);
return ResultGenerator.genSuccessResult();
}
Aggregations